﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZX.OA.Model;

namespace ZX.OA.DAL
{
  public  class AssentInfoDAL
    {
        Entity entity = new Entity();
        /// <summary>
        /// 公司资产表显示
        /// </summary>
        /// <returns></returns>
        public List<ZX.OA.Model.AssentInfo> ShowAssentInfo()
        {
            return entity.AssentInfo.ToList();
        }
        /// <summary>
        /// 公司资产表添加
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public int AddAssentInfo(ZX.OA.Model.AssentInfo a)
        {
            entity.AssentInfo.Add(a);
            return entity.SaveChanges();
        }
        /// <summary>
        /// 根据编号删除公司资产信息表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DelAssentInfo(int id)
        {
            entity.AssentInfo.Remove(entity.AssentInfo.Find(id));
            return entity.SaveChanges();
        }
        /// <summary>
        /// 获取公司类型表的id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AssentTypeInfo GetAssentTypeInfo(int id)
        {
            return entity.AssentTypeInfo.Find(id);
        }
        /// <summary>
        /// 修改公司资产信息表信息
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public int UptAssentInfo(AssentInfo a)
        {
            entity.Entry(a).State = System.Data.EntityState.Modified;
            return entity.SaveChanges();
        }
        /// <summary>
        /// 公司资产信息表的模糊查询
        /// </summary>
        /// <param name="AssentName"></param>
        /// <returns></returns>
        public List<ZX.OA.Model.AssentInfo> SreachAssentInfo(string AssentName)
        {
            return entity.AssentInfo.Where(p => string.IsNullOrEmpty(AssentName) ? true : p.AssentName.Contains(AssentName)).ToList();
        }
    }
}
